package com.oygo.hunter.decode;

import com.oygo.hunter.utils.EncTuils;

import java.security.GeneralSecurityException;

public class DecodeImpl implements IDecoder{
    @Override
    public boolean isDecode(String key, String msg) {
        return key != null && key.length() * 4 / 3 >= 0xFFFF;
    }

    @Override
    public String package_decode1(String key, String msg) {
        try {
            return EncTuils.decode(msg, key);
        }
        catch(GeneralSecurityException v2) {
            v2.printStackTrace();
            return key;
        }
    }

    @Override
    public String volatile_decide2(String key, String msg) {
        try {
            return EncTuils.encode(msg,key);
        }
        catch(GeneralSecurityException v2) {
            v2.printStackTrace();
            return key;
        }
    }

    private static final String type = "UTF-8";

    private static byte[] decodeBytes(byte[] arg7, String arg8) {
        int v1 = arg8.length();
        int v3 = 0;
        int v4;
        for(v4 = 0; v3 < arg7.length; ++v4) {
            if(v4 >= v1) {
                v4 = 0;
            }

            arg7[v3] = (byte)(arg7[v3] ^ arg8.charAt(v4));
            ++v3;
        }

        return arg7;
    }


}
